import request from '@/config/axios'

// 搜索食物
export const searchFoods = (keyword) => {
  return request({
    url: '/api/food/search',
    method: 'get',
    params: { keyword }
  })
}

// 获取所有食物分类
export const getAllCategories = () => {
  return request({
    url: '/api/food/categories',
    method: 'get'
  })
}

// 根据分类获取食物
export const getFoodsByCategory = (category) => {
  return request({
    url: `/api/food/category/${category}`,
    method: 'get'
  })
}

// 添加食物
export const addFood = (food) => {
  return request({
    url: '/api/food',
    method: 'post',
    data: food
  })
}

// 上传食物图片
export const uploadFoodImage = (foodId, formData, config = {}) => {
  return request({
    url: `/api/food/image/${foodId}`,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    ...config
  })
}

// 删除食物
export const deleteFood = (foodId) => {
  return request({
    url: `/api/food/${foodId}`,
    method: 'delete'
  })
} 